package com.zyh.service.impl;

import com.zyh.dao.UserMapper;
import com.zyh.entity.User;
import com.zyh.service.UserService;
import com.zyh.util.MybatisUtils;
import org.apache.ibatis.session.SqlSession;

public class UserServiceImpl implements UserService {
    SqlSession sqlSession = null;
    @Override
    public User selectByUsernameAndPassword(String username, String password) {
        User user = null;
        try {
            sqlSession = MybatisUtils.getSqlSession();
            UserMapper userMapper = sqlSession.getMapper(UserMapper.class);
            user = userMapper.selectByUsernameAndPassword(username, password);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            MybatisUtils.closeSqlSession(sqlSession);
        }
        return user;
    }
}
